# -*- coding: utf-8 -*-

from zinx.ziface.imessage import IMessage


class Message(IMessage):
    """
    将请求的一个消息封装到message中，定义抽象层接口
    """

    def __init__(self, m_id: int, m_len: int, m_data: bytes):
        self.id: int = m_id
        self.length: int = m_len
        self.data: bytes = m_data

    def GetDataLen(self) -> int:
        """
        获取消息数据段长度
        :return:
        """
        return self.length

    def GetMsgId(self) -> int:
        """
        获取消息ID
        :return:
        """
        return self.id

    def GetData(self) -> bytes:
        """
        获取消息内容
        :return:
        """
        return self.data

    def SetDataLen(self, m_len: int):
        """
        设置消息数据段长度
        :param m_len:
        """
        self.length = m_len

    def SetMsgId(self, m_id: int):
        """
        设置消息ID
        :param m_id:
        """
        self.id = m_id

    def SetData(self, m_data: bytes):
        """
        设置消息内容
        :param m_data:
        """
        self.data = m_data


def NewMessage(m_id: int, m_len: int, m_data: bytes) -> IMessage:
    ns = Message(m_id, m_len, m_data)
    return ns
